﻿using DocumentFormat.OpenXml.Lite.Helper;
using DocumentFormat.OpenXml.Lite.Interfaces;
using DocumentFormat.OpenXml.Lite.Shared;
using DocumentFormat.OpenXml.Lite.WordprocessingML.Word.Types;
using DocumentFormat.OpenXml.Lite.Xml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace DocumentFormat.OpenXml.Lite.WordprocessingML.Word.ParagraphProperties
{
    [XmlRoot("tabs", Namespace = Constants.WordMain)]
    public class Tabs : XmlSerializable, IParagraphPropElement
    {
        [XmlElement("tab", Namespace = Constants.WordMain)]
        public XmlList<Tab> TabElements { get; set; }

        public Tabs()
        {
            TabElements = new XmlList<Tab>();
        }

        public void Copy(object obj)
        {
            if (obj is Tabs)
            {
                this.TabElements = (obj as Tabs).TabElements;
            }
        }
    }

    [XmlRoot("tab", Namespace = Constants.WordMain)]
    public class Tab : XmlSerializable, ICopyable
    {
        [XmlAttribute("val", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public ST_TabJc StopType{get;set;}

        [Optional]
        [XmlAttribute("leader", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public Nullable<ST_TabTlc> TabLeaderCharacter{get;set;}

        [XmlAttribute("pos", Namespace = Constants.WordMain, Form = XmlSchemaForm.Qualified)]
        public int StopPosition { get; set; }

        public Tab() { }

        public void Copy(object obj)
        {
            if (obj is Tab)
            {
                this.StopType = (obj as Tab).StopType;
                this.StopPosition = (obj as Tab).StopPosition;
                this.TabLeaderCharacter = (obj as Tab).TabLeaderCharacter;
            }
        }
    }
}
